package com.geek.log4jcontrol.core;

import java.net.URL;
import java.util.Properties;

import com.geek.log4jcontrol.commons.ConfigConstants;
import com.geek.log4jcontrol.remote.RmiServer;

public class Log4jControl {

	public static void initService() {
		Properties prop = ConfigLoader.getInstance().getDefaultConfig();
		doInitService(prop);
	}

	public static void initService(String configFilename) {
		doInitService(configFilename);
	}

	public static void initService(URL configURL) {
		doInitService(configURL);
	}

	public static void initService(Properties properties) {
		doInitService(properties);
	}

	private static void doInitService(Object configParam) {
		ConfigLoader.getInstance().doConfigure(configParam);
		Log4jConfigControler log4jConfigControler = Log4jConfigControler.getInstance();
		log4jConfigControler.setCurrentConfig(log4jConfigControler.readCurrentConfig());
		RmiServer.createRegistry(ConfigConstants.SERVER_PORT);
		new RmiServer(ConfigConstants.SERVER_IP, ConfigConstants.SERVER_PORT, ConfigConstants.SERVER_RMINAME);
	}
}
